import _1_LoadTsFile
import _2_MergeTsFile
import _3_TsFileToMP4File
import os


if __name__ == '__main__':
    print(_1_LoadTsFile.getJson()["download_path"])
    # 请求ts文件的url根地址
    base_url = _1_LoadTsFile.getJson()["base_url"]
    _1_LoadTsFile.del_file(_1_LoadTsFile.getJson()["download_path"])
    m3u8_path = _1_LoadTsFile.get_ts_urls("", base_url)
    _1_LoadTsFile.download(m3u8_path, _1_LoadTsFile.getJson()["download_path"])

    # 
    download_path = _2_MergeTsFile.getJson()["download_path"]
    _2_MergeTsFile.combine(download_path, download_path, "combine")

    # 
    # 保存ts文件的保存地址
    download_path = _3_TsFileToMP4File.getJson()["download_path"]+"\combine.ts"
    # 转换后的地址
    combine_path = _3_TsFileToMP4File.getJson()["download_path"]+"\\video.mp4"
    com = "copy /b %s %s" % (download_path, combine_path)
    print(com)
    os.system(r"%s" % (com))